
* Change directory
* cd "C:\Users\omeryair88\Desktop"

*******************
** Main Analyses **
*******************

** Table 1 **

* Model 1 - Feeling thermometer (warmth) toward outgroup
reg warm_outgroup pos_relations neg_relations issue_agreement issue_disagreement 
outreg2 using Table_1.doc, replace se dec(2) alpha (.01, .05, .1) symbol (**, *, +) 
test pos_relations = neg_relations /*p = .096  */

* Model 2 - Ascription of positive traits for outgroup
reg positivetraits_outgroup pos_relations neg_relations issue_agreement issue_disagreement 
outreg2 using Table_1.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)  
test pos_relations = neg_relations /*p = .005*/

* Model 3 - Social distance (marriage) from outgroup
reg marriage_outgroup pos_relations neg_relations issue_agreement issue_disagreement 
outreg2 using Table_1.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +) 
test pos_relations = neg_relations /*p = .0001 */

* Model 4 - Social distance (co-worker) from outgroup
reg working_outgroup pos_relations neg_relations issue_agreement issue_disagreement 
outreg2 using Table_1.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +) 
test pos_relations = neg_relations /*p = .025 */

* Model 5 - Outgroup scale
reg outgroup_scale pos_relations neg_relations issue_agreement issue_disagreement 
outreg2 using Table_1.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +) 
test pos_relations = neg_relations /*p = .0007 */


************************************************
** Additional tests - for the online appendix **
************************************************

*** Table D1 ***
** Table 1, Models 1-5, with interactions b/w the two factors ***

gen issues_factor2=issues_factor
recode issues_factor2 (2=0) (1=1) (3=2)
label define lab_issues_factor2 0 "control" 1 "agreement" 2 "disagreement"
label values issues_factor2 lab_issues_factor2
tab issues_factor2

* Model 1 - Feeling thermometer (warmth) toward outgroup
reg warm_outgroup i.pos_relations##i.issues_factor2 i.neg_relations##i.issues_factor2 
outreg2 using Table_D1.doc, replace se dec(2) alpha (.01, .05, .1) symbol (**, *, +)

* Model 2 - Ascription of positive traits for outgroup
reg positivetraits_outgroup i.pos_relations##i.issues_factor2 i.neg_relations##i.issues_factor2 
outreg2 using Table_D1.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +) 

* Model 3 - Social distance (marriage) from outgroup
reg marriage_outgroup i.pos_relations##i.issues_factor2 i.neg_relations##i.issues_factor2 
outreg2 using Table_D1.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)  

* Model 4 - Social distance (co-worker) from outgroup
reg working_outgroup i.pos_relations##i.issues_factor2 i.neg_relations##i.issues_factor2 
outreg2 using Table_D1.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)

* Model 5 - Outgroup scale
reg outgroup_scale i.pos_relations##i.issues_factor2 i.neg_relations##i.issues_factor2 
outreg2 using Table_D1.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +) 


*** Table D2 ***
** Table 1 in the main text - separately for Dems. and Reps.  **

* Model 1 - Warmth - among Dems.
reg warm_outgroup pos_relations neg_relations issue_agreement issue_disagreement if party_dummy==0
outreg2 using Table_D2.doc, replace se dec(2) alpha (.01, .05, .1) symbol (**, *, +) 
test pos_relations = neg_relations /*p = .407*/

* Model 2 - Warmth - among Dems.
reg warm_outgroup pos_relations neg_relations issue_agreement issue_disagreement if party_dummy==1
outreg2 using Table_D2.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)
test pos_relations = neg_relations /*p = .128*/

* Model 3 - positive traits - among Dems.
reg positivetraits_outgroup pos_relations neg_relations issue_agreement issue_disagreement if party_dummy==0
outreg2 using Table_D2.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)
test pos_relations = neg_relations /*p = .219*/

* Model 4 - positive traits - among Dems.
reg positivetraits_outgroup pos_relations neg_relations issue_agreement issue_disagreement if party_dummy==1
outreg2 using Table_D2.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)
test pos_relations = neg_relations /*p = .006*/

* Model 5 - Social distance (marriage) - among Dems.
reg marriage_outgroup pos_relations neg_relations issue_agreement issue_disagreement if party_dummy==0
outreg2 using Table_D2.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)
test pos_relations = neg_relations /*p = .010*/

* Model 6 - Social distance (marriage) - among Reps.
reg marriage_outgroup pos_relations neg_relations issue_agreement issue_disagreement if party_dummy==1
outreg2 using Table_D2.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)
test pos_relations = neg_relations /*p = .003*/

* Model 7 - Social distance (co-worker) - among Dems.
reg working_outgroup pos_relations neg_relations issue_agreement issue_disagreement if party_dummy==0
outreg2 using Table_D2.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)
test pos_relations = neg_relations /*p = .353*/

* Model 8 - Social distance (co-worker) - among Reps.
reg working_outgroup pos_relations neg_relations issue_agreement issue_disagreement if party_dummy==1
outreg2 using Table_D2.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)
test pos_relations = neg_relations /*p = .022*/

* Model 9 - Outgroup scale - among Dems.
reg outgroup_scale pos_relations neg_relations issue_agreement issue_disagreement if party_dummy==0
outreg2 using Table_D2.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)
test pos_relations = neg_relations /*p = .088*/

* Model 10 - Outgroup scale - among Reps.
reg outgroup_scale pos_relations neg_relations issue_agreement issue_disagreement if party_dummy==1
outreg2 using Table_D2.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)
test pos_relations = neg_relations /*p = .001*/


*** Table D3 ***
** Model 5 in Table 1 - with moderators (partisan social identity; immigration scale) ***
* Model 1 - Outgroup scale - w. partisan social identity
reg outgroup_scale i.pos_relations##c.partisan_soc_iden i.neg_relations##c.partisan_soc_iden ///
issue_agreement issue_disagreement 
outreg2 using Table_D3.doc, replace se dec(2) alpha (.01, .05, .1) symbol (**, *, +)

* Model 2 - Outgroup scale - w. immigration scale
reg outgroup_scale pos_relations neg_relations i.issue_agreement##c.immigration_scale_ingroup ///
i.issue_disagreement##c.immigration_scale_ingroup 
outreg2 using Table_D3.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)



*** Table D4 - ingroup results ***
* Model 1 - Ingroup scale
reg ingroup_scale pos_relations neg_relations issue_agreement issue_disagreement 
outreg2 using Table_D4.doc, replace se dec(2) alpha (.01, .05, .1) symbol (**, *, +) 

* Model 2 - interactions b/w friendly/hostile conditions and partisan social identity
reg ingroup_scale i.pos_relations##c.partisan_soc_iden i.neg_relations##c.partisan_soc_iden ///
issue_agreement issue_disagreement 
outreg2 using Table_D4.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)

* Model 3 - interactions b/w issue agree./disagree. conditions and immigration scale
reg ingroup_scale pos_relations neg_relations i.issue_agreement##c.immigration_scale_ingroup ///
i.issue_disagreement##c.immigration_scale_ingroup 
outreg2 using Table_D4.doc, append se dec(2) alpha (.01, .05, .1) symbol (**, *, +)



***********************************************
*** Interactions b/w factors - for Figure 1 ***
***********************************************

reg outgroup_scale i.group_relations_factor##i.issues_factor2
margin i.group_relations_factor##i.issues_factor2, level(95)
margin i.issues_factor2##i.group_relations_factor, level(95)
*marginsplot


